Resister value calculation
Application
/* Name : main.c * Purpose : Source code for LED Interfacing with AT89C52. * Author : Gemicates * Date : 2014-01-12 * Website : www.gemicates.org * Revision : None */ #include <REGX52.H> //header file for AT89c52 series #define ledport P0 //To set a port pins as output sbit LED9=P3^7; //To set a single pin(P3.7) as output sbit LED10=P1^6; //To set a single pin(P1.6) as output sbit SW =P1^7; //To set a single pin(P1.7) as output unsigned char log=0; //Global variable declaration void delay(int msec) //delay function declaration { //This function produces a delay in msec int i,j; for(i=0;i<msec;i++) for(j=0;j<1275;j++); } void main() //main function { SW=0; //make as a input pin P1^7 while(1) //Repeat(loop) forever { //port declaration ledport=0x00; //P0 LEDs will be ON delay(50); ledport=0xFF; //P0 LEDs will be OFF //single pin declaration LED9=0; //LED 9 will be ON state delay(50); //function call for delay LED9=1; //LED 9 will be OFF state delay(50); //push button declaration if((SW==1)&&(log==0)) //LED turn ON using Push Button { LED10=0; delay(50); log=1; } if((SW==1)&&(log==1)) { LED10=~LED10; // Toggle state delay(50); log=0; } } }